{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'Vertex' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-2-465750c95107>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m     39\u001b[0m                 \"G\": 0,} #8\n\u001b[1;32m     40\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 41\u001b[0;31m \u001b[0mlgraph\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mLNodeGraph\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvertexes\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpositions\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mweights\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mheuristic\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     42\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     43\u001b[0m \u001b[0mlgraph\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdraw_init\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/zBox/projects/py_path_planner/backup/path_planner/node_graph.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, vertices, positions, weights, heuristic)\u001b[0m\n\u001b[1;32m     19\u001b[0m \u001b[0;32mclass\u001b[0m \u001b[0mLNodeGraph\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mNodeGraph\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m#save as linked list\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     20\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvertices\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpositions\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mweights\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mheuristic\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m#edges\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 21\u001b[0;31m         \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvertices\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvertices\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     22\u001b[0m         \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpositions\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpositions\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     23\u001b[0m         \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mweights\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mweights\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/zBox/projects/py_path_planner/backup/path_planner/node_graph.py\u001b[0m in \u001b[0;36mvertices\u001b[0;34m(self, vertices)\u001b[0m\n\u001b[1;32m     33\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvertices\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlist\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     34\u001b[0m             \u001b[0;32mfor\u001b[0m \u001b[0mchain\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mvertices\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 35\u001b[0;31m                 \u001b[0mhead\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mVertex\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mchain\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     36\u001b[0m                 \u001b[0mhead\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mweight\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     37\u001b[0m                 \u001b[0;32mfor\u001b[0m \u001b[0msub_vertex\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mchain\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mNameError\u001b[0m: name 'Vertex' is not defined"
     ]
    }
   ],
   "source": [
    "from node_graph import LNodeGraph\n",
    "from ver\n",
    "vertexes = [['S', 'A', 'B', 'C'],\n",
    "            ['A', 'S', 'D', 'E'],\n",
    "            ['B', 'S', 'E', 'F'],\n",
    "            ['C', 'S', 'K'],\n",
    "            ['D', 'A', 'G'],\n",
    "            ['E', 'A', 'B', 'G'], \n",
    "            ['F', 'B', 'K', 'G'],\n",
    "            ['K', 'C', 'F', 'G'],\n",
    "            ['G', 'D', 'E', 'F', 'K']]\n",
    "\n",
    "positions = {\"S\":[0.05, 0.5], #0\n",
    "            \"A\":[0.3, 0.8], #1\n",
    "            \"B\":[0.3, 0.5], #2\n",
    "            \"C\":[0.3, 0.2], #3\n",
    "            \"D\":[0.6, 0.95], #4\n",
    "            \"E\":[0.6, 0.65], #5\n",
    "            \"F\":[0.6, 0.4],  #6\n",
    "            \"K\":[0.8, 0.2], #7\n",
    "            \"G\":[0.99, 0.5],} #8\n",
    "\n",
    "weights = { ('S', 'A'): 9, ('S', 'B'): 6, ('S', 'C'): 8, ('A', 'S'): 9, ('B', 'S'): 6, ('C', 'S'): 8,\n",
    "            ('A', 'D'): 7, ('A', 'E'): 9, ('D', 'A'): 7, ('E', 'A'): 9,\n",
    "            ('B', 'E'): 8, ('B', 'F'): 8, ('E', 'B'): 8, ('F', 'B'): 8,\n",
    "            ('C', 'K'): 20, ('K', 'C'): 20,\n",
    "            ('D', 'G'): 16, ('G', 'D'): 16,\n",
    "            ('E', 'G'): 13, ('G', 'E'): 13, \n",
    "            ('F', 'G'): 13, ('F', 'K'): 5, ('G', 'F'): 13, ('K', 'F'): 5, \n",
    "            ('K', 'G'): 6, ('G', 'K'): 6 }\n",
    "\n",
    "heuristic = {   \"S\": 20, #0\n",
    "                \"A\": 15, #1\n",
    "                \"B\": 17, #2\n",
    "                \"C\": 15, #3\n",
    "                \"D\": 11, #4\n",
    "                \"E\": 12, #5\n",
    "                \"F\": 10,  #6\n",
    "                \"K\": 5, #7\n",
    "                \"G\": 0,} #8\n",
    "\n",
    "lgraph = LNodeGraph(vertexes, positions, weights, heuristic)\n",
    "\n",
    "lgraph.draw_init()\n",
    "lgraph.draw_vertices(heuristic=True)\n",
    "lgraph.draw_edges(weight=True)\n",
    "# lgraph.BFS('S')\n",
    "# lgraph.draw_BFS_tree()\n",
    "# lgraph.DFS()\n",
    "# lgraph.draw_DFS_forest()  \n",
    "# lgraph.Dijkstra('G')\n",
    "# lgraph.draw_Dijkstra_tree()\n",
    "lgraph.AStar('G', 'S')\n",
    "lgraph.draw_A_star_path('G', 'S')\n",
    "lgraph.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n",
      "<class '__main__.A'>\n",
      "<class 'type'>\n",
      "<class '__main__.A'>\n",
      "<class 'int'>\n",
      "<class 'int'>\n",
      "a is type\n",
      "b is type\n",
      "a in type [int, float, type]\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "class A():\n",
    "    pass\n",
    "\n",
    "a = A()\n",
    "b=2\n",
    "print(type(\"123\"))\n",
    "print(type(a))\n",
    "print(type(A))\n",
    "print(a.__class__)\n",
    "print(b.__class__)\n",
    "print(type(b))\n",
    "if isinstance(a.__class__, type):\n",
    "    print(\"a is type\")\n",
    "if isinstance(b.__class__, type):\n",
    "    print(\"b is type\")\n",
    "if type(b) in [int, float, type]:\n",
    "    print(\"a in type [int, float, type]\")\n",
    "if hasattr(b, \"__class__\"):\n",
    "    print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "print(1>>1)\n",
    "print(2>>1)\n",
    "print(3>>1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[3, 2, 1]\n"
     ]
    }
   ],
   "source": [
    "a = [1, 2, 3]\n",
    "print(a[::-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "398dc28c06ad810e77de546bbdfa897a6ee0b83e59a5207339dda01a7843e01d"
  },
  "kernelspec": {
   "display_name": "Python 3.7.0 64-bit ('base': conda)",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
